package com.DreamForce.Demo.persist.IbatisImpl;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.DreamForce.Demo.persist.DAO.ItemMapper;
import com.DreamForce.demo.model.Item;

@Service
public class ItemHandler {
	protected static Logger logger = Logger.getLogger(ItemHandler.class);
	
	@Autowired
	private ItemMapper itemMapper;
	  
	public  List<Item> getItemListByProduct(String productId)
	{
		List<Item> list;
		try {
			list = itemMapper.getItemListByProduct(productId);
		} catch (Exception e) {
			return null;
		}
		return list;
	}
	public Item getItem(String itemId)
	{
		Item item ;
		try {
			item = itemMapper.getItem(itemId);
		} catch (Exception e) {
			return null;
		}
		return item;
	}
	public int getInventoryQuantity(String itemId)
	{
		try {
			return itemMapper.getInventoryQuantity(itemId);
		} catch (Exception e) {
			return -1;  // -1 means error.
		}
	}
	public  boolean updateInventoryQuantity(Map<String, Object> param)
	{
		try {
			updateInventoryQuantity(param);
		} catch (Exception e) {
		    return false;
		}
		return true;
	}
}
